Skip to content

Conversation

@Hweinstock
Copy link
Contributor

@Hweinstock Hweinstock commented Nov 22, 2024

Problem

#6043
To reproduce, add a 5 second delay to the after hook at the top level.
One way to do this is to insert this at line 84.

after(async function () {
        clock.uninstall()
        await sleep(5000)
    })

Despite asserting that the promise rejects within the test, the promise rejects after the test as well. Not entirely sure why this happening.

  • Tried manually wrapping in try-catch with an await instead of assert.rejects and it still fails.
  • Tried wrapping the promise in another promise before passing to assert.rejects.

Solution

What does appear to work, is manually handling the callback of the promise. That is, explicitly defining a then and catch method to assert the rejection, and awaiting the promise at the end of the test to ensure it resolves before the test finishes. Not sure why this works, but I am unable to reproduce the error with this change.

Notes


License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Hweinstock Hweinstock marked this pull request as ready for review November 22, 2024 17:20
@Hweinstock Hweinstock requested a review from a team as a code owner November 22, 2024 17:20
Copy link
Contributor

@justinmk3 justinmk3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@justinmk3
Copy link
Contributor

justinmk3 commented Nov 27, 2024

This should allow use to remove Timed-out waiting for browser login flow\| from this ignore-pattern, now:

_ignore_pat='Timed-out waiting for browser login flow\|HTTPError: Response code 403\|HTTPError: Response code 404\|npm WARN deprecated querystring\|npm WARN deprecated'

Let's include that with this commit, since they are inherently coupled.

@Hweinstock Hweinstock changed the base branch from master to feature/postreinvent December 4, 2024 19:48
@Hweinstock Hweinstock merged commit c8bfe2f into aws:feature/postreinvent Dec 4, 2024
32 of 34 checks passed
@Hweinstock Hweinstock deleted the fixUnresolvedPromise branch December 4, 2024 22:56
karanA-aws pushed a commit to karanA-aws/aws-toolkit-vscode that referenced this pull request Jan 17, 2025
## Problem
aws#6043
To reproduce, add a 5 second delay to the `after` hook at the top level.
One way to do this is to insert this at line 84. 
``` 
after(async function () {
        clock.uninstall()
        await sleep(5000)
    })
```
Despite asserting that the promise rejects within the test, the promise
rejects after the test as well. Not entirely sure why this happening.
- Tried manually wrapping in try-catch with an `await` instead of
`assert.rejects` and it still fails.
- Tried wrapping the promise in another promise before passing to
`assert.rejects`.

## Solution
What does appear to work, is manually handling the callback of the
promise. That is, explicitly defining a `then` and `catch` method to
assert the rejection, and awaiting the promise at the end of the test to
ensure it resolves before the test finishes. Not sure why this works,
but I am unable to reproduce the error with this change.

## Notes
- `assert.rejects` implementation:
https://github.com/nodejs/node/blob/3178a762d6a2b1a37b74f02266eea0f3d86603be/lib/assert.js#L653.
Doesn't appear to be the problem because the same is observed when
manually wrapping.
- `await` docs:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await




---

<!--- REMINDER: Ensure that your PR meets the guidelines in
CONTRIBUTING.md -->

License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants